package lesson02;

/**
 * 演示后台线程
 *
 * @author wileda
 * @date 2023/01/04  12:26
 */
public class Demo02 {
    public static void main(String[] args) {
        Thread thread = new Thread(() -> {
            while(true) {
                System.out.println("hello thread...");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        //设置成后台线程
//        thread.setDaemon(true);
        //启动线程
        thread.start();
        System.out.println("是否存活:" + thread.isAlive());
        System.out.println("main方法执行完成");
    }
}
